package com.css.bjdt_report.explain.service;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.css.bjdt_report.explain.entity.RptExplainAreaTemporary;
import com.css.bjdt_report.util.CommonUtil;

@Service
public class RptExplainAreaTemporaryService {

	@Autowired
	private Dao dao;

	public List<RptExplainAreaTemporary> getAllRptExplainAreaTemporaryByExplainId(String explainId) {
		return dao.query(RptExplainAreaTemporary.class, Cnd.where("EXPLAIN_ID", "=", explainId));
	}

	public void deleteAllRptExplainAreaTemporaryByExplainId(String explainId) {
		dao.clear(RptExplainAreaTemporary.class, Cnd.where("EXPLAIN_ID", "=", explainId));
	}

	public RptExplainAreaTemporary saveRptExplainAreaTemporary(RptExplainAreaTemporary record) {
		if (StringUtils.isEmpty(record.getId())) {
			record.setId(CommonUtil.getUUID());
		}
		return dao.insert(record);
	}
}
